package games.ninJumpDx.ui.actions
{
	import flash.display.Bitmap;
	import flash.utils.getTimer;
	
	import games.ninJumpDx.data.GameData;
	import games.ninJumpDx.data.UIConfig;
	import games.ninJumpDx.tools.Tools;
	
	import utils.Cartoon;

	public class Building extends Cartoon
	{
		private var info:XMLList;
		public function Building(name:String)
		{
			super();
			addChild(Tools.getBitmapByName(name,GFrame.MAIN_UI));
			info = UIConfig.getInfoByName(name);
			x = info.@x;
			y = UIConfig.getInfoByName(name).@y;
			if(info.hasOwnProperty("@scaleX"))
			{
				scaleX = -1;
			}
		}
		
		override public function update(t:Object=null):void
		{
			if(!start || pause)return;
			if(y > UIConfig.getGameHeight())
			{
				destroy();
				return ;
			}
			y += GameData.instance.speed ; 
		}
		
		override public function destroy(e:* = null):void
		{
			super.destroy();
			info = null;
			while(numChildren > 0)
			{
				var mc:Bitmap = Bitmap(removeChildAt(0));
				mc.bitmapData.dispose();
			}
				
		}
	}
}